<template> 
  <div class="top-bar">
    <div class="top-bar-controls">


      <a @click="camemin" class="control-button">
        <MinusOutlined />
      </a>

      <a @click="camemax" class="control-button">
        <ExpandOutlined v-if="!isMaximized" />
        <CompressOutlined v-else />
      </a>

      <a @click="closeWindow" class="control-button close-button">
        <CloseOutlined />
      </a>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from "vue";
import { message } from "ant-design-vue";
import {
  MinusOutlined,
  ExpandOutlined,
  CompressOutlined,
  CloseOutlined,
  MoreOutlined,
} from "@ant-design/icons-vue";
import { Dropdown, Menu } from "ant-design-vue";

const electronAPI = window.electronAPI;

const isMaximized = ref(false);

const closeWindow = () => {
  electronAPI.hideWindow();
};

const camemax = () => {
  electronAPI.toggleFullscreen();
};

const camemin = () => {
  electronAPI.minimizeWindow();
};





const handleWindowMaximized = () => {
  isMaximized.value = true;
};

const handleWindowUnmaximized = () => {
  isMaximized.value = false;
};

onMounted(() => {
  electronAPI.onWindowMaximized(handleWindowMaximized);
  electronAPI.onWindowUnmaximized(handleWindowUnmaximized);
});


</script>

<style scoped>
.top-bar {
  width: 100%;
  height: 24px;
  -webkit-app-region: drag;
  background: transparent;
  position: relative;
}

.top-bar-controls {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  height: 100%;
}

.control-button {
  width: 24px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4a4a4a;
  background: transparent;
  transition: background-color 0.2s;
  -webkit-app-region: no-drag;
}

.control-button:hover {
  background-color: #f0f0f0;
}

.close-button:hover {
  background-color: #ff4d4f;
}
</style>
